using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using DTO;
using System.Data;

namespace HeThongDAO
{
    public class TheLoaiDAO
    {
        public static DataTable SelectAll()
        {
            string sql = "SELECT * FROM THE_LOAI";
            return Config.AccessHelper.ExecuteQuery(sql);
        }
        public static DataTable DocSchema()
        {
            return Config.AccessHelper.Doc_Cau_Truc("THE_LOAI");
        }
        public static void ThemTheLoai(TheLoaiDTO tl)
        {
            string sql = "insert into THE_LOAI(TenTheLoai) values ('@tentheloai')";
            sql = sql.Replace("@tentheloai", tl.StrTenTheLoai);
            Config.AccessHelper.ExecuteNonQuery(sql);
        }
        public static void CapNhatBang(DataTable dt, string ten_bang)
        {
            Config.AccessHelper.Ghi(dt, ten_bang);
        }
        public static void XoaTheLoai(TheLoaiDTO tl)
        {
            string sql = "DELETE FROM THE_LOAI WHERE MaTheLoai=@matheloai";
            sql = sql.Replace("@matheloai", tl.IMaTheLoai.ToString());
            Config.AccessHelper.ExecuteNonQuery(sql);
        }
        public static void CapNhatTheLoai(TheLoaiDTO tl)
        {
            string sql = "UPDATE THE_LOAI SET TenTheLoai='@tentheloai' WHERE MaTheLoai=@matheloai";
            sql = sql.Replace("@tentheloai", tl.StrTenTheLoai);
            sql = sql.Replace("@matheloai",tl.IMaTheLoai.ToString());
            Config.AccessHelper.ExecuteNonQuery(sql);
        }
    }
}
